package com.pqtest.api.controller;

import com.pqtest.api.annotation.Paging;
import com.pqtest.api.annotation.ResponseFormat;
import com.pqtest.api.service.CsTestItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class CsTestItemController extends BaseController {
    @Autowired
    CsTestItemService csTestItemService;

    @PostMapping("/item/search")
    @ResponseFormat(type = "withTotal")
    @Paging
    Object search(HttpServletRequest request){
        String text = request.getParameter("text");
        String[] texts = text.split("\\s");
        return csTestItemService.search("+"+String.join(" +",texts));
    }
}
